<!--
 * @Author: your name
 * @Date: 2022-01-21 12:54:56
 * @LastEditTime: 2022-01-21 13:26:41
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \算法测试\day0906\1345跳跃游戏.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var minJumps = function (arr) {
            let result = 0;
            let everyone = 0;
            let bushu = function (i) {
                if (i < 0) {
                    return;
                }
                if (i === arr.length - 1) {
                    if (everyone < result || result === 0) {
                        result = everyone;
                        everyone--;
                        return;
                    }
                }
                everyone++;
                bushu(i + 1);
                bushu(i - 1);
                let two = arr[i];
                arr[i] = 'a' + i;
                if (arr.indexOf(two) !== -1) {
                    bushu(arr.indexOf(two));
                }
            }
            bushu(0);
            return result;
        };
        console.log(minJumps([2, 1,2]));
    </script>
</body>

</html>